<template>
  <div class='aui-card--fill scroll-box card-box'>
    <div class='pane-shell'>
      <search @sumbit='sumbit'>
        <!--  搜索项 -->
        <template slot='form'>
          <el-form :inline='true'
                   @submit.native.prevent
                   :model='dataForm'
                   ref='dataForm'>
            <el-form-item prop='name'>
              <el-input v-model.trim='dataForm.name'
                        class='form-item'
                        clearable
                        maxlength="20"
                        show-word-limit
                        placeholder='品牌'></el-input>
            </el-form-item>
          </el-form>
        </template>
        <!--  操作按钮 -->
        <template slot='btns'>
          <el-button type="primary"
                     plain
                     @click="addWin()">新增品牌</el-button>
        </template>
      </search>
      <table-template :tableData='tableData'
                      :loading='dataListLoading'
                      :fieldManagement='false'
                      :index='true'
                      :dataList='dataList'>
        <el-table-column :label="$t('handle')"
                         fixed='right'
                         header-align='center'
                         align='center'
                         v-if="false"
                         width='120'>
          <template slot-scope='scope'>
            <el-button type='text'
                       class='brand'
                       v-if="$hasPermission('tb:device:updateDevice')"
                       @click='addWin(scope.row)'
                       size='small'>修改</el-button>
            <el-button type='text'
                       size='small'
                       class='danger'
                       v-if="$hasPermission('tb:device:deleteDevice')"
                       @click='deleteHandle({id:scope.row.id})'>{{ $t('delete')}}</el-button>
          </template>
        </el-table-column>
      </table-template>
      <el-pagination :current-page='page'
                     :page-sizes='[10,20,50,100]'
                     :total='total'
                     layout='total, sizes, prev, pager, next'
                     @size-change='pageSizeChangeHandle'
                     @current-change='pageCurrentChangeHandle'>
      </el-pagination>
    </div>
    <brandmanagementaddorupdate ref="addOrUpdate"
                                @callBack="getDataList" />
  </div>
</template>
<script>
import mixinViewModule from '@/mixins/view-module'
import minFormValidate from '@/mixins/form-validate'
import tableTemplate from '@/components/table-template'
import Search from '@/components/search/search'
import brandmanagementaddorupdate from './brand-management-add-or-update.vue'
export default {
  mixins: [mixinViewModule, minFormValidate],
  name: '',
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/tb/deviceBrand/queryPage', // 数据列表接口，API地址
        getDataListIsPage: true, // 数据列表接口，是否需要分页？
        addOrUpdateURL: '', // 添加或修改接口，API地址
        getDataInfoURL: '', // 数据详情，API地址
        updateStatusURL: '',
        deleteURL: '/tb/deviceBrand/', // 删除接口，API地址
        deleteIsBatch: true, // 删除接口，是否需要批量？
        exportURL: '' // 导出接口，API地址
      },
      dataForm: {
      }
    }
  },
  components: { tableTemplate, Search, brandmanagementaddorupdate },
  computed: {
    tableData () {
      return [
        { label: '品牌', width: '100', prop: 'name' },
        { label: '备注', width: '100', prop: 'remarks' },
        // { label: '更新人', width: '100', prop: 'updaterName' },
        // { label: '更新时间', width: '150', prop: 'updateDate' },
        { label: '创建人', width: '100', prop: 'creatorName' },
        { label: '创建时间', width: '150', prop: 'createDate' }
      ]
    }
  },
  mounted () {
  },
  methods: {
    sumbit () {
      this.$refs.dataForm.validate((valid) => {
        if (valid) {
          this.getPageInit()
        }
      })
    },
    addWin (_id) {
      if (_id) {
        this.$refs.addOrUpdate.init(_id)
      } else {
        this.$refs.addOrUpdate.init()
      }
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
